// PageGeneral.cpp : implementation file
//

#include "stdafx.h"
#include "greenftp.h"
#include "PageGeneral.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CPageGeneral property page

IMPLEMENT_DYNCREATE(CPageGeneral, CPropertyPage)

CPageGeneral::CPageGeneral() : CPropertyPage(CPageGeneral::IDD)
{
	//{{AFX_DATA_INIT(CPageGeneral)
	m_strEmail = m_pFtpConfig->m_strAnonymousEmail;
	m_bShowConOnStart = m_pFtpConfig->m_bShowConOnStart;
	m_bDelConfirm = m_pFtpConfig->m_bDelConfirm;
	m_bKeeplive = m_pFtpConfig->m_bKeeplive;
	m_bSavePos = m_pFtpConfig->m_bSavePos;
	m_iKeepAliveStart = m_pFtpConfig->m_iKeepAliveStart;
	m_iKeepAliveInterval = m_pFtpConfig->m_iKeepAliveInterval;
	m_bKeepAliveShowMsg = m_pFtpConfig->m_bKeepAliveShowMsg;
	m_strKeepAliveCmds = m_pFtpConfig->m_strKeepAliveCmds;
	m_sKeepAliveCmds = _T("");
	if(m_strKeepAliveCmds == "")
	{
		m_bKeepAliveCmdType = TRUE;
	}
	//}}AFX_DATA_INIT
}

CPageGeneral::~CPageGeneral()
{
}

void CPageGeneral::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPageGeneral)
	DDX_Control(pDX, IDC_KEEP_ALIVE_CMDS, m_cKeepAliveCmds);
	DDX_Text(pDX, IDC_EMAILADDRESS, m_strEmail);
	DDX_Check(pDX, IDC_DELETECONFIRMATION, m_bDelConfirm);
	DDX_Check(pDX, IDC_KEEPALIVE, m_bKeeplive);
	DDX_Check(pDX, IDC_SAVEPOSITION, m_bSavePos);
	DDX_Check(pDX, IDC_SHOWCONNECTDLG, m_bShowConOnStart);
	DDX_Control(pDX, IDC_SPIN_KEEP_ALIVE_START, m_spinKeepAliveStart);
	DDX_Control(pDX, IDC_SPIN_KEEP_ALIVE_INTERVAL, m_spinKeepAliveInterval);
	DDX_Text(pDX, IDC_EDIT_KEEP_ALIVE_START, m_iKeepAliveStart);
	DDX_Text(pDX, IDC_EDIT_KEEP_ALIVE_INTERVAL, m_iKeepAliveInterval);
	DDX_Check(pDX, IDC_KEEP_ALIVE_SHOW_MSG, m_bKeepAliveShowMsg);
	DDX_Check(pDX, IDC_KEEP_ALIVE_CMDTYPE, m_bKeepAliveCmdType);
	DDX_CBString(pDX, IDC_KEEP_ALIVE_CMDS, m_sKeepAliveCmds);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CPageGeneral, CPropertyPage)
	//{{AFX_MSG_MAP(CPageGeneral)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPageGeneral message handlers

BOOL CPageGeneral::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();
	
	// TODO: Add extra initialization here
	m_spinKeepAliveStart.SetRange(0,300);
	m_spinKeepAliveStart.SetBuddy(GetDlgItem(IDC_EDIT_KEEP_ALIVE_START));
	m_spinKeepAliveInterval.SetRange(0,300);
	m_spinKeepAliveInterval.SetBuddy(GetDlgItem(IDC_EDIT_KEEP_ALIVE_INTERVAL));

	for(int i=0;i<FTP_COMMAND_SIZE;i++)
	{
		m_cKeepAliveCmds.AddString(commands[i]);
		if(m_strKeepAliveCmds != "" && m_strKeepAliveCmds==commands[i])m_cKeepAliveCmds.SetCurSel(i);
	}
	if(m_strKeepAliveCmds == "")
	{
		m_bKeepAliveCmdType = TRUE;
		m_cKeepAliveCmds.SetCurSel(0);
	}
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
